//
//  HBRankItemController.m
//  HeartBeat
//
//  Created by karong on 2023/8/25.
//

#import "HBRankItemController.h"
#import "HBRankItemCell.h"
#import "HBRankRequest.h"

@interface HBRankItemController ()
@property (weak, nonatomic) IBOutlet UICollectionView *listView;
@property (nonatomic, strong) HBRankRequest * request;
@end

@implementation HBRankItemController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    HBRankRequest * request = [HBRankRequest new];
    self.request = request;
}

- (void)showNovelDetailWithNovel:(id)novel {
    [ViewManager pushNovelDetailVCWithNovel:novel inController:self];
}
#pragma mark - UICollectionViewDelete

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HBRankItemCell *rankItemCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HBRankItemCell" forIndexPath:indexPath];
    [rankItemCell setDataWithObject:self.dataArray[indexPath.row] index:indexPath.row];
    return rankItemCell;
}


#pragma mark - UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGSize size = CGSizeZero;
    size.width = HBScreenWidth;
    size.height = 92.5;
    return size;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    [self showNovelDetailWithNovel:self.dataArray[indexPath.row]];
}

- (void)setChannel_type:(NSInteger)channel_type {
    if (channel_type != _channel_type) {
        _channel_type = channel_type;
        self.request.sort_type = self.sort_type;
        self.request.channel_type = channel_type;
        [self benginRefresh];
    }
}
@end
